package cc.mrbird.alarm.domain;

import cc.mrbird.common.annotation.ExportConfig;
import com.fasterxml.jackson.annotation.JsonFormat;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

@Table(name="alarm_info")
public class AlarmInfo implements Serializable {
    /**
     * 设备ID、发生时间、告警类型、设备类型、所属网格、所属单位、设备地址、告警状态、详细信息链接\
     * 记录什么时间发现告警，什么时间将告警信息发送给责任单位，什么时间确认信息，什么时间处理完毕。
     * 为了方便记录，可以为每个告警信息提供一个唯一编号，方便记录告警处置流程，减少数据存储量。
     */
    private static final long serialVersionUID = 7780821232635881125L;
    @Id
    @GeneratedValue(generator = "JDBC")
    @Column(name = "alarmInfo_id")
    private Integer alarmInfo_id;

    @Column(name = "createTime")
    @ExportConfig(value = "发生时间",convert = "c:cc.mrbird.common.util.poi.convert.TimeConvert")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;

    @Column(name = "alarmType")
    @ExportConfig(value = "告警类型")
    private String alarmType;

    @Column(name = "deviceType")
    @ExportConfig(value = "设备类型")
    private String deviceType;

    @Column(name = "grid")
    @ExportConfig(value = "所属网格")
    private String grid;

    @Column(name = "unit")
    @ExportConfig(value = "所属单位")
    private String unit;

    @Column(name = "address")
    @ExportConfig(value = "设备地址")
    private String address;

    @Column(name = "alarmStatus")
    private Integer alarmStatus; //0表示待定 ,1表示已确认,2表示已处理

    @ExportConfig(value = "告警状态")
    private String alarmStatusStr;

    @Column(name = "detailsLink")
    @ExportConfig(value = "详细信息链接")
    private String detailsLink;

    private String group_concat;
    @Column(name = "nextTime")
    private String nextTime;   //  用于显示最近时间,以小时、天、周、月为单位

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Integer getAlarmInfo_id() {
        return alarmInfo_id;
    }

    public void setAlarmInfo_id(Integer alarmInfo_id) {
        this.alarmInfo_id = alarmInfo_id;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getAlarmType() {
        return alarmType;
    }

    public void setAlarmType(String alarmType) {
        this.alarmType = alarmType;
    }

    public String getDeviceType() {
        return deviceType;
    }

    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }

    public String getGrid() {
        return grid;
    }

    public void setGrid(String grid) {
        this.grid = grid;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Integer getAlarmStatus() {
        return alarmStatus;
    }

    public void setAlarmStatus(Integer alarmStatus) {
        this.alarmStatus = alarmStatus;
    }

    public String getAlarmStatusStr() {
        if(alarmStatus==0){
            alarmStatusStr="待定";
        }
        if(alarmStatus==1){
            alarmStatusStr="已确认";
        }
        if(alarmStatus==2){
            alarmStatusStr="已处理";
        }
        return alarmStatusStr;
    }


    public void setAlarmStatusStr(String alarmStatusStr) {
        this.alarmStatusStr = alarmStatusStr;
    }

    public String getDetailsLink() {
        return detailsLink;
    }

    public void setDetailsLink(String detailsLink) {
        this.detailsLink = detailsLink;
    }

    public String getNextTime() {
        return nextTime;
    }

    public void setNextTime(String nextTime) {
        this.nextTime = nextTime;
    }

    public String getGroup_concat() {
        return group_concat;
    }

    public void setGroup_concat(String group_concat) {
        this.group_concat = group_concat;
    }

    @Override
    public String toString() {
        return "AlarmInfo{" +
                "alarmInfo_id=" + alarmInfo_id +
                ", createTime=" + createTime +
                ", alarmType='" + alarmType + '\'' +
                ", deviceType='" + deviceType + '\'' +
                ", grid='" + grid + '\'' +
                ", unit='" + unit + '\'' +
                ", address='" + address + '\'' +
                ", alarmStatus=" + alarmStatus +
                ", alarmStatusStr='" + alarmStatusStr + '\'' +
                ", detailsLink='" + detailsLink + '\'' +
                ", group_concat='" + group_concat + '\'' +
                ", nextTime='" + nextTime + '\'' +
                '}';
    }
}
